<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserHistoryLearnQuestionCountsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_history_learn_question_counts', function (Blueprint $table) {
            $table->id();
            $table->integer('userId', false, true)->index()->comment('用户 id');
            $table->string('reason')->nullable()->comment('记录产生原因');
            $table->integer('allCount')->default(0)->index()->comment('总数');
            $table->integer('correctCount')->default(0)->index()->comment('总正确数');
            $table->integer('wrongCount')->default(0)->index()->comment('总错题数');
            $table->timestamps();
        });

        DB::statement("ALTER TABLE user_history_learn_question_counts comment '用户答题数量统计记录'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_history_learn_question_counts');
    }
}
